package com.hzwq.demo.Login.repository;

import com.hzwq.demo.Login.bo.SdteUser;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;


public interface SdteUserRepository extends CrudRepository<SdteUser, Long>, JpaSpecificationExecutor {

    @Query(value = "select u.user_id,u.login_name,u.login_pwd,u.user_name,u.mobile,u.email,u.create_time,u.last_login_time,u.role_Id,(select r.ROLE_NAME FROM sdte_role r where r.ROLE_ID = u.role_id) as role_name from sdte_user u where u.login_name = ?1",nativeQuery = true)
    public SdteUser findUser(String loginName);

    @Query(value = "select u.user_id,u.login_name,u.login_pwd,u.user_name,u.mobile,u.email,u.create_time,u.last_login_time,u.role_Id,(select r.ROLE_NAME FROM sdte_role r where r.ROLE_ID = u.role_id) as role_name from sdte_user u where u.user_id = ?1",nativeQuery = true)
    public SdteUser findUserById(long userId);
}
